package com.tc.cursoflex.controller
{
	import com.tc.cursoflex.event.ShoutsEvent;
	import com.tc.cursoflex.model.ApplicationModel;
	import com.tc.cursoflex.domain.Shouter;
	import com.tc.cursoflex.domain.ShouterTimeline;
	
	import flash.display.DisplayObject;
	
	import flashx.textLayout.elements.GlobalSettings;
	
	import mx.core.Application;
	import mx.core.FlexGlobals;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;
	import mx.rpc.remoting.RemoteObject;
	
	import org.swizframework.metadata.PostConstructMetadataTag;
	import org.swizframework.utils.services.ServiceHelper;
	
	public class ShoutsController
	{
		public var ro:RemoteObject = new RemoteObject("shouts");
		
		[Inject]
		public var sh:ServiceHelper;
		
		[Bindable]
		[Inject(source="applicationModel")]
		public var model:ApplicationModel;
		
		[EventHandler(event="ShoutsEvent.GET_TIMELINE_FOR")]
		public function getTimelineFor(event:ShoutsEvent):void
		{
			var shtl1:ShouterTimeline = new ShouterTimeline();
			var shtl2:ShouterTimeline = new ShouterTimeline();
			var shtl3:ShouterTimeline = new ShouterTimeline();
			
			shtl1.message = "Hola a todo el mundo";
			shtl1.shouter = model.loggedShouter;
			
			shtl2.message = "Hola";
			
			shtl3.message = "Cómo va?";
			shtl3.shouter = model.loggedShouter;
			
			var sh2:Shouter = new Shouter();
			sh2.email = "pepe@gmail.com";
			sh2.imageUrl = "http://profile.ak.fbcdn.net/hprofile-ak-snc4/203296_639575102_815527_q.jpg";
			sh2.name = "Pepe Escamoso";
			shtl2.shouter = sh2;
			
			model.shouterTimeline.addItem(shtl1);
			model.shouterTimeline.addItem(shtl2);
			model.shouterTimeline.addItem(shtl3);
		}
		
		[EventHandler(event="ShoutsEvent.GET_SHOUTS_OF")]
		public function handleAdContactEvent(event:ShoutsEvent):void
		{
		}
		private function onFailHandler(o:Object):void
		{
			trace("hola");
		}
	}
}